<?php

namespace app\propaganda\controller;

use app\common\model\Banner;
use app\common\model\Post;
use library\Controller;

class Index extends Controller
{
    /**
     * 轮播图列表
     * @return void
     * @throws \think\Exception
     * @throws \think\db\exception\DataNotFoundException
     * @throws \think\db\exception\ModelNotFoundException
     * @throws \think\exception\DbException
     * @throws \think\exception\PDOException
     * @menu true
     * @auth true
     */
    public function banner()
    {
        $this->title = "轮播图列表";
        $db = (new Banner());
        $this->_page($db);
    }

    /**
     * @return void
     * @throws \think\Exception
     * @throws \think\db\exception\DataNotFoundException
     * @throws \think\db\exception\ModelNotFoundException
     * @throws \think\exception\DbException
     * @throws \think\exception\PDOException
     */
    public function bannerForm()
    {
        $this->_form("Banner");
    }

    public function bannerDelete()
    {
        Banner::destroy([
            "id" => input('id')
        ]);
        $this->success('删除成功');
    }

    /**
     * 公告列表
     * @return void
     * @throws \think\Exception
     * @throws \think\db\exception\DataNotFoundException
     * @throws \think\db\exception\ModelNotFoundException
     * @throws \think\exception\DbException
     * @throws \think\exception\PDOException
     * @menu true
     * @auth true
     */
    public function post()
    {
        $this->title = '公告列表';
        $db = (new Post());
        $this->_page($db);
    }

    public function postForm()
    {
        $this->_form('Post');
    }

    public function postDelete()
    {
        Post::destroy([
            'id' => input('id')
        ]);
        $this->success('删除成功');
    }

}